package com.medusa.aps.business.modules.demand.model.input;

import com.medusa.aps.business.model.constant.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Range;

import java.time.LocalDate;

/**
 * 新增订单实体参数
 *
 * @author shenzhiwei
 */
@Schema(description = "订单实体对象")
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "orderNumber")
@Accessors(chain = true)
public class OrderParam {

    /**
     * 订单号 不能为空 且必须是字母、数字或两者的组合
     */
    @Schema(description = "订单号", minLength = 1, maxLength = 50, pattern = RegexPool.ORDER_NO)
    @NotBlank(message = "订单号不能为空")
    @Size(min = 1, max = 50, message = "订单号长度必须在1-50之间")
    @Pattern(regexp = RegexPool.ORDER_NO, message = "订单号必须是字母、数字、英文字符的一种或者几种的组合")
    private String orderNumber;

    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    @NotBlank(message = "物料编码不能为空")
    @Size(min = 1, max = 50, message = "物料编码长度必须在1-50之间")
    @Pattern(regexp = RegexPool.ORDER_NO, message = "物料编码必须是字母、数字、英文字符的一种或者几种的组合")
    private String itemCode;

    /**
     * 客户编码
     */
    @Schema(description = "客户编码")
    @Size(min = 1, max = 50, message = "客户编码长度必须在1-50之间")
    @Pattern(regexp = RegexPool.ORDER_NO, message = "客户编码必须是字母、数字、英文字符的一种或者几种的组合")
    private String customerCode;

    /**
     * 下单日期
     */
    @Schema(description = "下单日期")
    @NotNull(message = "下单日期不能为空")
    private LocalDate orderDate;

    /**
     * 订单交期
     */
    @Schema(description = "订单交期")
    @NotNull(message = "订单交期不能为空")
    private LocalDate orderDeliveryDate;

    /**
     * 订单数量
     */
    @Schema(description = "产品数量")
    @NotNull(message = "产品数量不能为空")
    @Min(1)
    private Integer orderQuantity;

    /**
     * 订单优先级
     */
    @Schema(description = "订单优先级")
    @NotNull(message = "订单优先级不能为空")
    @Range(min = 1, max = 10, message = "订单优先级取值范围为1-10")
    private Integer orderPriority;

}
